package ${project_path}.${model.applicationId}.service.imp;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hbdiy.common.model.po.${model.javaClass}PO;
import ${project_path}.${model.applicationId}.service.${model.javaClass}Service;


@Service
public class ${model.javaClass}ServiceImp extends SqlSessionDaoSupport implements ${model.javaClass}Service {
	// 由系统工具生成的数据库表的DAO对象文件 可参照hbdiy-metadata工程相关代码
	private static String nameSpace = "com.hbdiy.common.dao.table.mapper.${model.javaClass}POMapper.";

	@Transactional
	// TODO 表中写入一条数据
	public void insert(${model.javaClass}PO record) {
		super.getSqlSession().insert(nameSpace + "insertSelective", record);
	}

	@Transactional
	// TODO 通过主键ID批量删除mm_goods 表中数据
	public void deleteDatas(String ids) {
		String[] idArray = ids.split(",");
		for (int i = 0; i < idArray.length; i++) {
			String id = idArray[i];
			 super.getSqlSession().delete(nameSpace+"deleteByPrimaryKey", id);
		}
	}

	@Transactional
	// TODO 通过主键修改表中数据
	public void update(${model.javaClass}PO record) {
		super.getSqlSession().update(nameSpace + "updateByPrimaryKeySelective", record);
	}

	// TODO 通过主键读取表中数据
	public ${model.javaClass}PO get${model.javaClass}PO(String id) {
		return super.getSqlSession().selectOne(nameSpace + "selectByPrimaryKey", id);
	}
}
